package org.waveplayer.section;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class ArrayAdapter extends RecyclerView.Adapter<ArrayAdapter.Holder> {

    private Object objects[];

    public ArrayAdapter(Object... objects) {
        this.objects = objects;
    }

    @NonNull
    @Override
    public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new Holder(LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_list_item_1, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull Holder holder, int position) {
        holder.title.setText(objects[position].toString());
    }

    @Override
    public int getItemCount() {
        return objects.length;
    }

    public static class Holder extends RecyclerView.ViewHolder {
        public TextView title;

        public Holder(@NonNull View itemView) {
            super(itemView);
            title = itemView.findViewById(android.R.id.text1);
        }
    }
}
